<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j"
	template="/WEB-INF/templates/template.xhtml">

	<ui:define name="breadcrumb">
		<ui:include src="breadcrumb.xhtml" />
	</ui:define>
	<ui:define name="menu">
		<ui:include src="/admin/menu.xhtml" />
	</ui:define>

	<ui:define name="title">#{messages.provinciaEdit}</ui:define>
	<ui:define name="content">
		<h:form method="post">
			<rich:graphValidator value="#{provinciaBean.entity}" id="gv">
				<rich:panel header="#{messages.provinciaData}">
					<rich:messages for="gv" 
						infoClass="green" 
						errorClass="red" 
						globalOnly="true" 
						ajaxRendered="true" />
					<h:panelGrid columns="3">
						<label for="pais">#{messages.provinciaPais}:</label>
						<rich:select id="pais" 
							enableManualInput="true" 
							defaultLabel="#{messages.ingresarValor}"						
							value="#{provinciaBean.entity.pais}" 
							converter="#{paisBean.converter}">
							<f:selectItems value="#{paisBean.allEntities}" 
								var="paisVar"
								itemLabel="#{paisVar.name}"	/>	
							<rich:validator/>
							<a4j:ajax event="selectitem" execute="@this"/>
						</rich:select>
						<rich:message for="pais" ajaxRendered="true"/>
						
						<label for="name">#{messages.provinciaNombre}:</label>
						<h:inputText id="name" 
							value="#{provinciaBean.entity.name}">
							<rich:validator/>
							<a4j:ajax event="change" execute="@this"/>
						</h:inputText>
						<rich:message for="name" ajaxRendered="true"/>

						<f:facet name="footer">
				        	<h:panelGrid columns="2">
								<h:commandButton value="#{messages.submit}" 
									action="#{provinciaBean.persist}"/>
								<h:commandButton value="#{messages.cancel}" 
									action="#{provinciaBean.cancel}"
									immediate="true"/>
							</h:panelGrid>					
						</f:facet>
					</h:panelGrid>
				</rich:panel>
			</rich:graphValidator>
		</h:form>
	</ui:define>	
</ui:composition>
